import { EventEmitter } from 'events';
import { errorResponseHandler } from '../middlewares/responseHandler';
export interface EventEmitterOptions {
    /**
     * Enables automatic capturing of promise rejection.
     */
    captureRejections?: boolean | undefined;
}
/**
 * 事件派发中心
 */
class Emitter extends EventEmitter {
    private static emitter: EventEmitter = null;
    private constructor(options?: EventEmitterOptions) {
        super(options)
    }
    public static getInstance(options?: EventEmitterOptions): Emitter {
        if (!Emitter.emitter) {
            Emitter.emitter = new Emitter(options);
        }
        return Emitter.emitter;
    }
}
const emitter = Emitter.getInstance();
emitter.addListener('errorResponse', errorResponseHandler);
export default emitter;